package com.linewell.serviceImpl;

import com.linewell.dao.IUserDao;
import com.linewell.pojo.Administrator;
import com.linewell.pojo.Msg;
import com.linewell.pojo.UserInfo;
import com.linewell.service.IUserService;
import com.linewell.util.query.QueryEntity;
import com.linewell.util.query.QueryOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Title: springBoot+mongodb+thymeleaf
 * @description:
 * @author: hyuhuang@linewell.com
 * @since:2018/4/28
 */
@Service
public class UserService implements IUserService{

    @Autowired
    IUserDao userDao;

    public UserInfo checkPunsterName(String punsterName) {
        return userDao.checkPunsterName(punsterName);
    }

    public UserInfo checkNamePwd(String punsterName, String password) {
        Map<String, QueryEntity> map = new HashMap<String, QueryEntity>();
        //条件一 id=5c8909ff764c4e2eb795557511d01053
        QueryEntity entity = new QueryEntity();
        entity.setField("punsterName");
        entity.setValue(new String[]{punsterName});
        entity.setType(new QueryOperator[]{ QueryOperator.IS });
        //条件二
        QueryEntity entity2 = new QueryEntity();
        entity2.setField("password");
        entity2.setValue(new String[]{password});
        entity2.setType(new QueryOperator[]{ QueryOperator.IS });
        map.put(entity.getField(),entity);
        map.put(entity2.getField(),entity2);
        //map 多条件   new Integer[]{1} 是排序降序，new String[]{ "createtime" } 按createtime排序
        return userDao.checkNamePwd(map);
    }

    public Msg saveUserInfo(UserInfo userInfo) {
        userDao.saveUserInfo(userInfo);
        return Msg.success();
    }

    @Override
    public boolean uploadUserPicture(String picture, Long userId) {
        return false;
    }

    @Override
    public Msg getHotUser(int page) {
        return null;
    }

    @Override
    public Administrator checkAdmin(String punsterName, String password) {
        return null;
    }

    @Override
    public Msg updataUserInfo(String userId, String nickName, String sex, String birthday, String userEmail, String myself) {
        return null;
    }

    @Override
    public Msg changePwd(Long userId, String oldPwd, String newPwd) {
        return null;
    }

    @Override
    public List<UserInfo> getUsers(int page, int limit) {
        return null;
    }

    @Override
    public int getUserCount() {
        return 0;
    }

    @Override
    public List<UserInfo> getUsersByPunsterName(String keyword) {
        return null;
    }

    @Override
    public Msg deleteAllUser(String userIds) {
        return null;
    }

    @Override
    public Msg deleteUserByUserId(Long userId) {
        return null;
    }

    @Override
    public Msg updateUserState(Long userId, int state) {
        return null;
    }

    @Override
    public Msg updateUser(String field, String value, Long userId) {
        return null;
    }
}
